package com.jiuyun.servlet;

import com.google.gson.Gson;
import com.jiuyun.vo.ChartData;
import com.jiuyun.vo.Radar;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/echarts/*")
public class EchartsServlet extends BaseServlet {

    Gson gson=new Gson();

    protected void echarts(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String title[]={"衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"};
        int data[]={50, 200, 360, 100, 100, 200};
        ChartData cd=new ChartData(title,data);
        String s = gson.toJson(cd);

        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json");//返回json
        PrintWriter out=response.getWriter();
        out.print(s);//数据
        out.flush();
        out.close();
    }
    protected void radar(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String title[]={"衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"};
        int data[]={5, 20, 36, 10, 10, 20};
        int max[]={100,100,100,100,100,100};
        Radar cd=new Radar(title,data,max);
        String s = gson.toJson(cd);

        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json");//返回json
        PrintWriter out=response.getWriter();
        out.print(s);//数据
        out.flush();
        out.close();
    }
}
